<template>
	<view class="eval-all">
		<view class="Sarch">
			<image class="input-uni-icon" src="https://image.nanjingtouyang.com/touy/2024/02/21/5cdd5c1dcfec4f0bbb40d7204f3ea8b9.png" mode=""></image>
			<input confirm-type="search" v-model="searchText" class="nav-bar-input" type="text" placeholder="请输入评论人昵称/手机号"
				@input="confirmInput" />
		</view>
		
		
		<view class="eval-box">
			<view class="eval-none-box" v-if="total == 0">
				<image class="eval-box-none-img" src="https://image.nanjingtouyang.com/touy/2023/10/2023103113282150383.png" mode="" style="width: 200rpx;height: 204rpx;"></image>
				<view class="eval-none-text">呜呜呜～还没有评价</view>
			</view>
			<view class="eval-box-list" v-else>
				<view class="eval-box-item" v-for="(item, index) in evalList" :key="index">
					<!-- 用户头像，昵称，时间和评分 -->
					<view class="eval-box-item-top">
						<view class="item-top-head" @click="toUserPage(item)">
							<image v-if="item.userAvatar" class="head-image" :src="item.userAvatar" mode=""></image>
							<image v-else class="head-image" src="https://image.nanjingtouyang.com/touy/2023/09/2023090515054870864.png" mode=""></image>
						</view>
						<view class="item-top-infos">
							<view class="item-top-infos-top">
								<view class="item-top-infos-top-name">{{ item.userName }}</view>
								<view class="item-top-infos-top-time">{{ item.createTime }}</view>
							</view>
							<view class="item-top-infos-bottom">
								<u-rate :count="count" v-model="item.score" active-color="#69AB5D" inactive-color="#e0dede" disabled></u-rate>
							</view>
						</view>
					</view>
					<!-- 评论部分 -->
					<view class="eval-box-item-bottom">
						<view class="" v-show="item.comment">
							<view class="eval-box-texts-short" v-if="item.lookAll==false">
								<text>{{ item.comment }}</text>
							</view>
							<view class="eval-box-texts-all" v-else>
								<text>{{ item.comment }}</text>
							</view>
						</view>
						
						<view class="push-and-pull" v-if="item.moreShow">
							<view class="push-item"  v-if="item.lookAll==false" @click="lookAllComment(index)">
								<view class="item-title">全文</view>
								<image class="item-img" src="https://image.nanjingtouyang.com/touy/2023/08/2023082213240347534.png" mode=""></image>
							</view>
							<view class="push-item" v-else @click="closeAllComment(index)">
								<view class="item-title">收起</view>
								<image class="item-img" src="https://image.nanjingtouyang.com/touy/2023/08/2023082213295798750.png" mode=""></image>
							</view>
						</view>
						<!-- 图片展示 -->
						<view class="eval-box-images">
							
							<view :class="item.imageLength == 4? 'eval-box-images-box eval-box-images-four' : 'eval-box-images-box'">
								<image v-for="(items, indexs) in item.fileList"  @click="previewImgEval(index, indexs)" :key="indexs" class="box-images-item" :src="items" mode="aspectFill"></image>
							</view>
						</view>
					</view>
					<view class="eval-box-num">
						订单编号
					</view>
				</view>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	// import { getActivityList } from "@/api/index.js"
	import { qrySpEval } from "@/api/mine.js"
	export default {
		data() {
			return {
				evalList: [],
				total: '',
				count: 5,
				searchText: ''
			}
		},
		onLoad() {
			this.getEvalList()
		},
		onReachBottom() {
			
		},
		methods: {
			confirmInput() {
				this.getEvalList()
			},
			previewImgEval(index, indexs) {
				uni.previewImage({
				  current: indexs,
				  urls: this.evalList[index].fileList.map(x => x)
				})
			},
			getEvalList() {
				qrySpEval({
					userName: this.searchText,
					pageNum: 1,
					pageSize: 100
				}).then(res => {
					this.total = res.data.data.length
					this.evalList = res.data.data
					this.evalList.forEach(item => {
						item.imageLength = item.fileList.length
						item.contentLength = item.comment.length
						if(item.contentLength > 100) {
							item.lookAll = false
							item.moreShow = true
						} else {
							item.lookAll = true
							item.moreShow = false
						}
					})
				})
			},
		}
	}
</script>

<style lang="scss">
	@import './eval-list.scss';
</style>